#!/usr/bin/env bash

set -ex

if [ -f /etc/lsb-release ]; then
    # In Ubuntu
    apt-get update && apt-get install -y pkg-config libhdf5-dev ffmpeg libsm6 libxext6
fi

if [ -n "${BENTO_PATH}" ] || [ -f /.dockerenv ]; then
    # We need to export LD_PRELOAD inside bento container.
    SITE_PACKAGES=$(python3 -c "import site; print(site.getsitepackages()[0])")

    export LD_PRELOAD=$(find "$SITE_PACKAGES/torch/lib/" -name "libgomp*" -printf "%p\n")
fi
